<template>
  <div class="reMv" @click="goPlaymv(item.id)">
    <div class="top">
      <img :src="item.picUrl" alt />
      <!-- 定位 -->
      <div class="Play-time">
        <!-- 播放  -->
      </div>
      <div class="Play-time1">
        <div class="play">
          <i class="iconfont icon-video">{{ playC }}</i>
        </div>
        <div class="time">{{ getTimes }}</div>
      </div>
    </div>
    <div class="bottom vuw2Text">{{ item.name }}</div>
  </div>
</template>

<script>
export default {
  //接收父组件的数据
  props: {
    item: {
      type: Object,
    },
  },
  //计算属性=》后台给的数据
  computed: {
    playC() {
      let data = 0;
      if (this.item.playCount > 10000) {
        //toFixed 计算数据保留一位
        data = (this.item.playCount / 10000).toFixed(1) + "万";
      } else {
        data = this.item.playCount;
      }

      return data;
    },
    getTimes() {
      return this.getTime(this.item.duration);
    },
  },
  methods: {
    getTime(data) {
      let s = data / 1000;
      let m = Math.floor(s / 60);
      if (m >= 10) {
        //表示 分钟大于等于10 =》 10:秒
        // 10:秒
        if (s - 60 * m >= 10) {
          return `${m}:${s - 60 * m}`;
        } else {
          //小于10前面添加一个0
          return `${m}:0${s - 60 * m}`;
        }
      } else {
        // 01：
        if (s - 60 * m >= 10) {
          return `0${m}:${s - 60 * m}`;
        } else {
          return `0${m}:0${s - 60 * m}`;
        }
      }
    },
    //点击跳转页面
    goPlaymv(id) {
      //$route :路由信息 $router:路由方法
      this.$router.push({ path: "/playmv", query: { id: id } });
    },
  },
};
</script>

<style scoped lang='less'>
.reMv {
  width: 48%;
  height: 700px;
  margin-bottom: 40px;
  .top {
    width: 100%;
    height: 500px;
    position: relative;
    img {
      height: 100%;
      width: 100%;
      border-radius: 50px 50px 0 0;
    }
    .Play-time {
      position: absolute;
      height: 100px;
      width: 100%;
      background: rgb(158, 131, 131);
      bottom: 0;
      opacity: 0.2;
      display: flex;
      justify-content: space-between;
      padding: 0 30px;
      //    border-radius: 50px 50px 0 0;
      align-items: center;
    }
    .Play-time1 {
      position: absolute;
      height: 100px;
      width: 100%;
      bottom: 0;
      display: flex;
      justify-content: space-between;
      padding: 0 30px;
      align-items: center;
      color: #fff;
      i {
        color: #fff;
      }
    }
  }
}
</style>
